<?php
	ini_set('session.save_path', '/tmp');
	session_start();
	if (isset($_SESSION['uname'])) {
		$totalTimeWatched = intval($_REQUEST['totalTimeWatched']);
		$videoName = $_REQUEST['videoName'];
		$mysql_username = "root";
		$mysql_password = "nitrkl123";
		$mysql_host = "127.0.0.1";
		$mysql_database = "video_tracking";
		
		$link = mysql_connect($mysql_host, $mysql_username, $mysql_password) or die("Could not connect to database:".mysql_error());
		mysql_select_db($mysql_database, $link) or die("Could not set database");
		
		$insert_query = "INSERT INTO video_time_viewed(username,video,viewed_time) VALUES('".$_SESSION['uname']."','".$videoName."',".$totalTimeWatched.")";
		mysql_query($insert_query, $link);
		mysql_close($link);
	}
?>